import { propertyMap } from '@shared/decorators/property-map'
import { IPagination } from './pagination'
import { IQueryParams } from './queryParams'
import { Contact } from './contact'
import { User } from './user'

export interface IGroupQueryParams extends IQueryParams {
  createTime?: string,
  insCode?: string,
  insName?: string,
  agentCode?: string,
  agentName?: string,
}

export class AgentFull {
  agent: Agent
  users: User[] = []
  constructor() {
    this.agent = new Agent()
  }
}

export class Agent {
  common: GroupCommon
  version?: number
  createdAt?: string
  updatedAt?: string

  constructor() {
    this.common = new GroupCommon()
  }
}

export class GroupCommon {
  /* 新的接口 */
  insCode: string
  insName: string
  insNameEN: string
  agentCode: string
  agentName: string // 集团（本地）名称
  agentNameEN: string // 集团英文名称
  contact: Contact
  status: string

  /* 旧的接口 */
  agentNum: string
  @propertyMap('createTime')
  createdAt: string
  @propertyMap('updateTime')
  updatedAt: string
  users: User[] // 该字段只有在新建集团的时候才用

  constructor() {
    this.contact = new Contact()
    // this.users = []
  }
}

export interface IGroupPagination extends IPagination {
  data: Agent[]
}
